
from re import A
from sqladmin import ModelView
from model import user


class UserAdmin(ModelView, model=user.User):
    name = "用户"
    name_plural = "用户"
    column_list = [user.User.id, user.User.username, user.User.password]
    column_labels = {"id": "用户id", "username": "用户名", "password": "密码", "gold_coins": "积分",
                     "is_deleted": "是否删除", "create_time": "创建时间", "update_time": "更新时间"}
    column_searchable_list = [user.User.username]
    column_sortable_list = [user.User.id]
    column_default_sort = [("id", True)]


class GoldCoinsInfoAdmin(ModelView, model=user.GoldCoinsInfo):
    name = "积分类型"
    name_plural = "积分类型"
    column_list = [user.GoldCoinsInfo.id,
                   user.GoldCoinsInfo.gold_coins, user.GoldCoinsInfo.text]
    column_labels = {"id": "id", "gold_coins": "积分", "text": "积分描述", "gold_coins_type": "积分类型",
                     "is_deleted": "是否删除", "create_time": "创建时间", "update_time": "更新时间"}
    column_searchable_list = [user.GoldCoinsInfo.text]
    column_sortable_list = []


class GoldCoinsLogAdmin(ModelView, model=user.GoldCoinsLog):
    name = "积分日志"
    name_plural = "积分日志"
    column_list = [user.GoldCoinsLog.id, user.GoldCoinsLog.gold_coins_info,
                   user.GoldCoinsLog.source_user, user.GoldCoinsLog.target_user]
    column_labels = {"id": "id", "gold_coins_info": "积分类型", "source_user": "来源用户",
                     "target_user": "目标用户", "blog_id": "博客ID", "is_deleted": "是否删除", "create_time": "创建时间", "update_time": "更新时间"}
